<{include file="tpl/header.html"}>
<link href="tpl/js/uploadify/uploadify.css" type="text/css" rel="stylesheet" />		
<input type="hidden" name="session_id" id="session_id" value="<{$smarty.session.ID}>" />

<h2 class="ytadmin-h2">添加图片
	<a class="pull-right btn btn-info" href="<{spUrl c=picture a=index cat_id=$cat_id}>">返回列表</a>
</h2>
<div class="clearfix">
	<div class="clearfix pull-left" style="width:380px;margin-right:20px;">
		<form class="form-horizontal" role="form" style="margin:15px 0 -10px">
  			<div class="form-group">
				<label for="cat" class="col-sm-3 control-label">分类：</label>
				<div class="col-xs-9" style="margin-bottom:15px;">
					<select class="form-control" name="cat_id" id="cat"  disabled>
							<{foreach key=key item=cat_item from=$cat_result}>
								<{if $cat_id==$cat_item['id']}>
									<option value="<{$cat_item['id']}>" selected="selected"><{$cat_item['list_tab']}> <{$cat_item['name']}></option>
								<{else}>
									<option value="<{$cat_item['id']}>"><{$cat_item['list_tab']}> <{$cat_item['name']}></option>
								<{/if}>
							<{/foreach}>
					</select>
				</div>
			</div>
		</form>	
		<div id="picture_upload" style="padding:10px;border:1px dotted #ccc;background-color:#eee;">		
			<span class="label label-success pull-right">最多50张</span>
			<span class="label label-success pull-right">小于8M</span>
			<span class="label label-success pull-right">gif、jpg、png格式</span>
			<input  id="file_upload" name="file_upload" type="file" />
			<input onclick="javascript:$('#file_upload').uploadify('upload','*')" type="button" id="upload" class="btn btn-info" value="上传"/>		
			<input onclick="javascript:$('#file_upload').uploadify('cancel','*')" type="button" id="cancel" class="btn btn-warning" value="清除"/>
		</div>
	</div>
	<div id="picture_show" class="">
		<h3 class="inline">标题编辑区</h3>
		<hr />
		<form action="<{spUrl c=picture a=add}>" method="post">
		<div id="picture_box" style="height:310px;overflow-y:scroll;"></div>
		<hr />
		<input type="hidden" name="cat_id" value="<{$cat_id}>">
		<input type="submit" name="submit" class="btn btn-info" value="提交">
		</form>
	</div>
</div>
<script type="text/javascript" src="tpl/js/uploadify/jquery.uploadify-3.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {	
	$('#file_upload').uploadify({
	'uploader'  : 'index.php?c=picture&a=picture_ajax',
	'swf'       : 'tpl/js/uploadify/uploadify.swf',
	'checkExisting' : 'tpl/js/uploadify/uploadify-check-exists.php',
	'fileSizeLimit' : '8000KB',
	'auto'      : false,
	'multi'		: true,
	'fileTypeDesc' : '图像文件',
	'fileTypeExts' : '*.gif;*.jpg;*.png',
	'queueSizeLimit' : 50,
	'progressData' : 'all',
	'formData' : {cat_id:$('#cat').val(),session_id:$('#session_id').val()},
	'removeCompleted' : false,
	'onUploadSuccess' : function(file,data,response) { 
		var data = eval('('+data+')');
		var html = '<div class="thumbnail col-md-4">';
		html += '<img width="210px" src="../'+data.dir+'_temp.jpg">';
		html += '<div class="caption" style="padding:5px 0">';
		html += '<p>标题：<input type="text" name="title[]" value="'+data.name+'"/></p>';
		html += '<p>描述：<input type="text" name="description[]" value="'+data.name+'"/></p>';
		html += '<input type="hidden" name="id[]" value="'+data.id+'"/>';
		html += '</div>';
		html += '</div>';
		$('#picture_box').append(html);
	}  
	});
});
</script>

<{include file="tpl/footer.html"}>